package com.ruoyi.business;

import com.ruoyi.business.enumType.TriggerType;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.scheduling.Trigger;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class Test {

    public static void main(String[] args) {
        try {

            // 指定Python解释器路径和Python脚本路径
            String[] args1 = new String[] { "python", "D:\\pythoFile\\sub_tick_manual.py", "SHSE.515700"};//第二个为python脚本所在位置，后面的为所传参数（得是字符串类型）
            Process process = Runtime.getRuntime().exec(args1);

            // 读取Python脚本的输出
            BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(), "gb2312"));
            BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8));

            // 输出Python脚本的标准输出和标准错误
            String s;
            while ((s = stdInput.readLine()) != null) {
                System.out.println(s);
            }
            while ((s = stdError.readLine()) != null) {
                System.err.println(s);
            }

            // 等待Python脚本执行完毕并获取退出状态
            int exitCode = process.waitFor();
            System.out.println("\nExited with error code : " + exitCode);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
